namespace ASPNET.StarterKit.IssueTracker.BusinessLogicLayer
{
    using System;
    using System.Collections;
    using System.Reflection;

    public class CategoryCollection : CollectionBase
    {
        public int Add(Category value)
        {
            return this.List.Add(value);
        }

        public bool Contains(Category value)
        {
            return this.List.Contains(value);
        }

        public int IndexOf(Category value)
        {
            return this.List.IndexOf(value);
        }

        public void Insert(int index, Category value)
        {
            this.List.Insert(index, value);
        }

        protected override void OnInsert(int index, object value)
        {
            if (value.GetType() != Type.GetType("ASPNET.StarterKit.IssueTracker.BusinessLogicLayer.Category"))
            {
                throw new ArgumentException("value must be of type Category.", "value");
            }
        }

        protected override void OnRemove(int index, object value)
        {
            if (value.GetType() != Type.GetType("ASPNET.StarterKit.IssueTracker.BusinessLogicLayer.Category"))
            {
                throw new ArgumentException("value must be of type Category.", "value");
            }
        }

        protected override void OnSet(int index, object oldValue, object newValue)
        {
            if (newValue.GetType() != Type.GetType("ASPNET.StarterKit.IssueTracker.BusinessLogicLayer.Category"))
            {
                throw new ArgumentException("newValue must be of type Category.", "newValue");
            }
        }

        protected override void OnValidate(object value)
        {
            if (value.GetType() != Type.GetType("ASPNET.StarterKit.IssueTracker.BusinessLogicLayer.Category"))
            {
                throw new ArgumentException("value must be of type Category.");
            }
        }

        public void Remove(Category value)
        {
            this.List.Remove(value);
        }

        public Category this[int index]
        {
            get
            {
                return (Category) this.List[index];
            }
            set
            {
                this.List[index] = value;
            }
        }
    }
}

